﻿# -*- coding: utf-8 -*-

import sys
if sys.platform == "win32":
    from mx_win32 import *
elif sys.platform == "cli":
    from mx_cli import *
else:
    raise Exception("Sorry: no implementation for your platform ('%s') available" % sys.platform)
from cpytype import *


class Dummy():
    _control_ = "Dummy"
    
    def __init__(self, *args):
        pass

    def open(self):
        self.isOpen = True
        
    def close(self):
        self.isOpen = False
        
    def getCpuType(self):
        return "Dummy", 0

    def __getitem__(self, device):
        return 0

    def __setitem__(self, device, value):
        pass

    def read(self, device, size):
        return [0]*size

    def write(self, device, data):
        pass
        
    def readlist(self, devlist):
        return [0]*len(devlist)
        
    def writelist(self, data):
        pass

    def readBuffer(self, startIO, address, size):
        return [0]*size

    def writeBuffer(self, startIO, address, data):
        pass


class EasyIF(Base):
    _control_ = "ActMulti.ActMLEasyIF"

    def __init__(self, *args):
        super(EasyIF, self).__init__(*args)
        #self.plc.ActPassword = password


class Usb(Base):
    _control_ = "ActPcUsb.ActMLQCPUQUSB"

    def __init__(self, *args):
        super(Usb, self).__init__(*args)


class Udp(Base):
    _control_ = "ActEther.ActMLQNUDECPUUDP"

    def __init__(self, *args, **kwargs):
        super(Udp, self).__init__(*args)
        if "direct" in kwargs:
            self.plc.ActDirectConnectBit = kwargs["direct"]

class Llt(Base):
    _control_ = "ActLlt.ActMLLLT"

    def __init__(self, *args):
        super(Llt, self).__init__(*args)
